#include <mpi.h>
#include <stdio.h>

int main(int argc, char **argv) {
	int size, rank;
	int memInt[2];
	MPI_Status status;
	
	MPI_Init( &argc, &argv );
    MPI_Comm_size( MPI_COMM_WORLD, &size );
    MPI_Comm_rank( MPI_COMM_WORLD, &rank );
	
	if (rank == 0) {
		for (int i = 1; i < size; ++i) {
			MPI_Recv(memInt, 2,	MPI_INT, i, 0, MPI_COMM_WORLD, &status );
			printf("%d\n",memInt[0]);
		}
	} else {
		memInt[0] = rank;
		memInt[1] = 1;
		MPI_Send(memInt, 2, MPI_INT, 0, 0, MPI_COMM_WORLD );
	}
	
	MPI_Finalize();
	return 0;
}
